﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Locator.LcboServices.PageLoaders.Services;
using LcboServices.Common.Tests;
using Locator.LcboServices.BusinessEntities;
using Locator.LcboServices.LcboProductsService.Services;

namespace LcboProductsService.Tests
{
    [TestFixture]
    public class Tests
    {
        [Test]
        public void GetOneProduct()
        {
            using (LcboProductServiceAgent agent = new LcboProductServiceAgent(new LocalFilePageRetrieverFactory()))
            {
                string description = agent.GetProductDescription("53884");
                Assert.AreEqual("Labatt Blue 710 mL can", description);
            }
        }

        [Test]
        public void GetAllProducts()
        {
            using (LcboProductServiceAgent agent = new LcboProductServiceAgent(new LocalFilePageRetrieverFactory()))
            {
                List<LcboProduct> products = agent.GetAllProducts();
                Assert.AreEqual(10399, products.Count);
                Assert.AreEqual("#92 Vintage Port Douro (Quinta De La Rosa)", products[0].Name);
                Assert.AreEqual(1, products[0].Container.NumberOfContainers);
                Assert.AreEqual(750M, products[0].Container.ContainerCapacity);
                var productPorqueNo = (from p in products
                                       where p.Name == "Tres Sabores ¿Porqué No? 2007"
                                       select p).Single();
                Assert.AreEqual(1, productPorqueNo.Container.NumberOfContainers);
                Assert.AreEqual(750M, productPorqueNo.Container.ContainerCapacity);
                var productTrereAlbana = (from p in products
                                          where p.Name == "Trerè Albana 2007"
                                          select p).Single();
                Assert.AreEqual(1, productTrereAlbana.Container.NumberOfContainers);
                Assert.AreEqual(750M, productTrereAlbana.Container.ContainerCapacity);
                var productMeshachShiraz = (from p in products
                                            where p.Name == "00 Meshach Shiraz (Grant Burge)"
                                            select p).Single();
                Assert.AreEqual(6, productMeshachShiraz.Container.NumberOfContainers);
                Assert.AreEqual(125M, productMeshachShiraz.Container.ContainerCapacity);
                Assert.AreEqual(120.00M, productMeshachShiraz.Price);
            }
        }
    }
}
